/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package charge;

import java.text.DecimalFormat;
import java.text.Format;

/**
 *
 * @author houfukude
 */
public class Charge{
    static int[] money = new int[] {500,200,100,50,20,10,5,2,1};
    static int[] theCharge = new int[9];
    
    public static void charge(int charge,int i){
        theCharge[i] = charge / money[i];
        charge = charge%money[i];
        Format   format=new   DecimalFormat( "0.0");
        if(theCharge[i]!=0){
                System.out.println("找零 "+theCharge[i]+"张"+format.format((double)money[i]/10)+"元");
            }
        
        if(charge>=0&&i<8){
            charge(charge,i+1);
        } 

    }

    
}
